

Modeling Tutorial

Table of Contents:

Conceptual considerations
Before you can begin to build anything to go into Half-Life, it helps to have a good idea of what will and will not work within the context of the engine.  There are certain concerns, described below, which may have a big impact on what you would like to do.  The two major areas you should consider: does your concept work within the technical limitations of the engine, and does your concept have any unworkable artistic issues?
Engine limitations
In a perfect world, anything that would be cool or fun to create would work within the limits of the engine. This isn't the case.  
Polygon Budgets
The first thing to consider is: can you realistically build a model that bends and moves and looks like you want it to with the number of polygons that your design demands.  The first thing to consider when deciding on a polygon count is; how many do you want to see on screen at any given time.  If you only see one monster and nothing else, you can have a model in upwards of 3000 polygons.  If you want a monster that shows up in groups of six to ten, you should divide 3000 by the number appearing to arrive at your polygon number.  For example, if you want to create a giant spider that travels in packs of up to 6, you should not make each one more than 500 polygons.  Once you decide how many polygons the thing possibly could be, you need to decide where the important shapes are and where it can bend.  Any polygon that isn't describing a shape, or allowing for movement flexibility should be removed.
Bounding Box
A bounding box is the shape that determines where the monster can move within the world.  As far as the movement code in the engine is concerned, the monster is the bounding box: if the bounding box can fit through a doorway, the model will be able to move through, regardless of the appearance of the actual monster geometry. Ideally your creature should fit nicely into one of the bounding boxes.  There are three sizes: 32x32x36 (the size of the player character crouched); 32x32x72 (the size of a standing player); 64x64x64 (the size used for all larger creatures).  If portions of your creature stick out from the hull of one of these bounding boxes, then you risk having those features also clip into the walls of the world, or into the player's view if the player is close to the monster.
Formal Artistic issues
Creating creatures and characters for a video game may seem like a new genre or art form. Really, it is just a combination of very old genres and types of artistic expression.  When you create the mesh for your creature, you are making sculpture. When you skin your monster, you are painting.  All the old rules apply, so do yourself a favor and find out about them.  You'd be surprised to see how much you can learn by looking at painting and sculpture that isn't in the fantasy/sci-fi genre.
Model as sculpture
When you take a concept drawn on paper and model it in three dimensions, you may find that your creation doesn't look as interesting from some angles.  This is a primary problem in sculpture.  When you make a drawing you only have to account for one point of view: with sculpture, the position of the viewer isn't really known.  When creating for games, you must take into consideration the behavior of the creature.  Some creatures always face you, some often run away.  The behavior will tell you which viewing angles you need to worry the most about.  To make the shape of your monster work for you, you should look at it as a silhouette from the most common angles (based on behavior).  If the silhouette isn't interesting, then you're going to have to work that much harder with textures to make it interesting.  On the other hand, if the silhouette is interesting from all angles, then your textures can work for you on other levels, instead of just compensating for bad shape.
Textures as paintings
When you create textures for your model, make sure that you look at them as relief.  The model has the big shapes in it, but the textures have to create the illusion of all the subtle surface features.  You also have to think of how the lightmap on the model will mix with the textures: if you look at the untextured model, how will the dark and light areas created by the surface contours affect your textures?
FOV 
One particularly annoying problem with creating models is the 90-degree field of view in the game.  This in effect makes everything look as if it were viewed from a fisheye lens.  What most commonly happens is that at close range, everything at player eye level is grossly enlarged, while that which is further away is drastically shrunk.  When close to a correctly proportioned human model, for example, the head will look bulbous and distorted while the feet will look too small.  You can correct somewhat for this, but these adjustments also become obvious when not close to the model in question.  I've seen some modelers make their heads small and their feet big, but all this really does is make the model look wrong.  This is another example of when you should make your model work for the behavior you have in mind.  If the creature attacks from long range, make it look good at long range, if the creature runs up and does a melee attack all the time, make your model optimized for up close viewing.
Near/Far perception

This is another hard-learned problem.  If you watch an experienced painter make an oil painting, they will periodically step away from the canvas to see how their composition works at medium and far distances.  When up close, the details and surface quality are most readily appreciated, but when far away, the underlying structure and large masses of light and dark define the image.  The same holds true for textures on game models.  You must take into consideration what your character looks like up close, and far away.  As stated above, the small details are very important, but the often-overlooked qualities of broad light and dark shapes are just as important.  It is often best to take a big brush in whatever software package you use, (I use Metacreations Painter 5) and define the largest possible groupings of light and shadow, then narrow your focus down over time, leaving painting the details until the end.
Movement/conventions
When you are first designing a creature, think of how it moves.  Too many people take bipedal, human like movement for granted.  The whole legacy of making human-like monsters goes back to Hollywood: if you make your monster look like a person, you can use a man in a monster suit instead of a puppet.  Fortunately, you never have to make a person fit into your monster, so go crazy with never before seen body types.  If you look at photographs of animals, make sure to notice how differently they are all designed.  Taking inspiration from microscopic organisms, deep-sea creatures, insects, and other animals can be a big help in getting away from creatures that look like bodybuilders with animal masks on.  The only real limitations you have when designing your creature are polygon counts and bounding boxes. 
Creating Geometry
Once you have decided on what it is you want to make, and you've considered all of the technical and artistic aspects of that process, it's time to make some meshes.  The best way I've found to approach building a complicated shape is to think of the major parts separately.  If you were to build a human, you may construct the head, arms, legs, and torso separately.  Once you have these parts roughed out, you can arrange them in the proper position and begin to work on the object as a whole.
Modeling programs
You can use whatever 3d program you want to create the initial mesh, so long as it can export to a format that 3ds Max can read.  If in doubt as to what 3ds Max can read, check www.3dcafe.com or www.ktx.com   they have lots of info on plugins and importers/exporters.  When specific solutions for modeling problems are mentioned below, it will be in the context of 3DS Max 1.2.
Max
Ted, Doug, and Steve use 3DS Max to create meshes, but this isn't the only or best way to go about it.  Max does have a number of cool nurbs modellers available for it, (I'll talk about them below).  Max 2 also has a spline/nurbs system built in, too, but none of the creatures of Half-Life were built using that system, so we haven't thoroughly investigated it.
Animation Master
Chuck uses Animation Master's spline modeler to rough out his meshes.  It gives great results in a short period of time.  It needs a better name though.
Plugins
The major plugin that is not merely useful but is in fact necessary for Half-Life model creation is Character Studio.  Character Studio is used to generate the animation of all Half-Life characters.

Some of our favorites for Max include Digimation's Clay Studio Pro: it has a primitive called a clay spline, which can end up looking like a muscle, depending on how you create it.  Laying out a creature by making it's major muscles is a very intuitive way for some to work, and once you have the muscles laid out, the program generates a surface mesh for you, based on your requirements.  This process often needs many hours of reduction time though, because like splines, the mesh you end up with will usually be many thousands of polygons.
Smoothing Groups
Smoothing groups are a nice feature of the Half-Life engine.  Without smoothing between faces, the whole model would appear faceted, the light value for each triangle would be radically different from the next.  Some games smooth the whole model together, without any option for the modeler to separate out portions that should remain distinct. The screenshots below show a model with smoothing groups, faceted and smoothed all together.  Use smoothing groups to create seams, some common ones on humans are clothing 
seams, like boots, pants helmets, etc.  You can play with the exact configuration of smoothing groups until you have lighting that you like.

Setting default lighting
The default lighting scenario in Max is two omni lights that are on either side of the world origin, this most often gives you a very poor picture of what your model will look like in the game.  Before you get too seriously into making smoothing groups for your model, you will want to recreate the model lighting that the game uses.  The best way we have found to do this is to set the ambient light to about 32.  After this, create a ring of omni lights around and above your model.

Edit mesh modifier
Once you've constructed your components, (arms, legs, head, torso) it's time to stitch them together into one mesh.  The first part of this process usually involves using the attach button to make all of the components the same object.  After you've done this you can identify where in the model you have overlapping parts.  One common one is where the leg goes into the torso: here one should delete the faces that overlap inside the torso and thigh.  You will then have a gap in your mesh. At this point, you can build new faces and/or target weld vertices together to get a smooth joint.  Insuring that you have some extra faces here for smooth bending of the hip will help your model look good through all of its poses in animation.
Bisecting
One good trick you can use to make your model more efficient and to save yourself some time is to bisect the model and work on one half.  This works in most cases where you have bilateral symmetry.  This saves you from creating all the joints and welds on both sides.  Once you have one half that looks the way you want it to, you can mirror the object, attach both pieces, and use "Edit mesh: Weld: Selected".  Select the row of vertices that goes along the split make sure they are all lined up and then weld with the threshold set very low.
Stitching
Stitching refers to creating by hand new faces in your model to get a desired result.  This is most commonly done where two sub-assemblies join, as described before, you usually start by deleting the overlapping faces.  Once you delete these faces, you are left with a gap in your mesh that goes around the entire joint.  Depending on the resolution of your mesh, you may have to use "target weld", "build face" and "collapse" to get an efficient joint. 
Target weld
In many cases, you may wish to use the "Edit mesh: vertex: weld: target" command.  This lets you define the geometry better than the collapse and selected weld commands.  After you've deleted the overlapping faces described above, you can find vertices that line up approximately.  Once you've found a set, select target weld then drag a vertex over the vertex that you want to weld it to.  Target weld is great for creating joints, but it also helps in the optimization process, if you find a face or set of faces that aren't doing much for your model, you can just drag the offending vertices over to one of their neighbors.
Edges
Edges are the most often overlooked part of the edit mesh modifier.  By manipulating the edges of your model using the "turn" command, you can create more efficient joints, create better detail and lighting, and polish your model to the point where all the parts of it are working to maximum effect.  
Optimize
This is a useful tool in the initial reduction process. Make sure you try using optimize both on the whole model and on parts selected with edit mesh.  After you've lowered the resolution (number of faces) you'll have to do some manual correction.  Usually you can use edit mesh's turn edge command to get back most of the detail you want.
Textures
Models in Half-Life can use any number of textures on them.  The real limit is the total memory size your palletized textures occupy according to studiomdl.exe.  Try to keep the total memory space of your textures below 150k.  In addition to regular texture maps, you can assign any face or group of faces to have "chrome" mapping.  In this type of map you use a 64x64 texture, the engine stretches the texture out to fit the selected set of faces.  In the engine the map that you use is always sliding around to face the player.  It is similar to an environmental map, if you are familiar with those.  Once created all maps for the creature must be 256 colors, each with its own unique palette.
UVW mapping
In the modifier panel of 3ds Max, there is an entry called "UVW map".  This is how you describe how your bitmap it to be projected onto the mesh.  The most commonly used form of mapping is planar, although you can use box mapping and cylindrical mapping.  The "gizmo," or orange object that appears is a 3d representation of your bitmap, can be transformed like geometry to slide, scale and repeat your textures.
Multi/Sub object materials
To begin to show maps on your geometry, open the materials editor, select one of the materials and push the "type" button.  A new window now appears, under "browse from" select new, then select "multi/sub object mapping" from the listed types.   Now you will see a list of materials appear in the materials editor, each one represents a material id number from the model.  You can change the number of sub materials at any time by simple pressing the "set number" button.  For each of the materials listed, you can have one texture map.  Assign a texture map to a material number by expanding the maps rollout.  Check the box next to diffuse map and press the map box on the right, and in the next window, select "new", and then "bitmap".  When you press "ok", you will be returned to the bitmap parameter rollout where you select the bitmap button and load your map.  To make your map visible in the viewport, press the "show map in viewport" button on the toolbar, just below the material-view window (the icon for this button is a cube with a blue and white checkerboard on it.)  Repeat this process for each material number on your model.
Modifier stack 
Once you have selected a group of faces to share a map with the "edit mesh" modifier, select "uvw map" and assign the map you created in the materials editor.  If you have multiple maps on your model, your modifier stack will be a series of "edit mesh" modifiers separated by "uvw map" modifiers.
Windows clipboard Transfer
One very easy way to map your creature is to do use the "printscreen" button to copy the current screen to the windows clipboard: in Max, I usually view the model from an orthographic view (front, top, right, left, bottom, back).  Once I have selected a group of faces, assigned a material id to it, I apply a "uvw map" and align the gizmo to be square with the viewport.  Use the "printscreen" button and paste the screen image into your paint program, use the outline of the gizmo to get the correct aspect ratio and use the wireframe image of the model as a template for making that texture. Once you have the entire model mapped, you can use a 3d-paint program to clean up the seams in the maps.  (4d paint and Texturizer are the best utilities we've used.)
The Skeleton
At this point, you have a character whose geometry is complete and who is fully textured.  To make this creature eventually move about, you need to devise some kind of bones to bend the model realistically at all joints.  Nearly all characters that walk use some form of the modified biped from Character Studio.  You can use plain Max bone systems, but they can be time consuming.  Usually I'll take the biped and change it's shape and number of components to fit what I'm doing.  This usually leaves a few gaps, but you can attach extra bones to the biped with great success.
Using Character Studio's Biped
Make sure to use the "apply increment" feature that occurs if you right click on a group of selected keys in the track view.  It can be a great tool in getting motion that really feels real.
Using 3d Studio Bones
A great way to create and copy keys on Max bones is to right click on the time slider at the bottom of the screen, this will create or copy keys for all the selected objects.  Make sure to learn how to use the IK panel, setting up proper limits and parameters for your joints will go a great way to make animation a simpler process.  With bones you can use full suite of Max controllers and expressions to create very clean motion.
Physique Modifier
This is the only part of Character Studio you really need. This modifier lets you attach a mesh to a bone system and then assign vertices to the bones.  This is pretty straightforward, but you may only use rigid, (green) vertices.  Make sure to use the pelvis as your root bone.
Animation
There is no way one can possibly give all the info required to do good animations, but suffice to say all motion originates at an object's center of mass.  If you don't pay attention to the crucial movements of the spine, hips and pelvis, you can never make a character animation that has weight and balance.  Even though the motions of the limbs are the most visible, they cannot make up for poor motion near the center of gravity.  As a general rule of thumb, animate from the center of gravity out, leaving the limbs and head for last.  Start a walk cycle by animating the motion of the root node: this gives the forward distance to travel, the side to side motion of the hips and the rotational motion of the hips as weight is shifted to each side.
Types of animation
Most of the work you will do will be manual, (keyframed) animation, but be aware that you can let the animation engine do some of the harder work for you.
Manual
This is where the bulk of the animation work is.  The process is roughly as follows.  In time configuration, set the length of the animation.  Define your beginning and ending pose, then roughly place poses in between the beginning and end.  Once you have the rough motion, you can begin to define the subtleties of motion.  After you make some of the smaller motions, start to adjust the timing in the track view.  This adjustment of timing is accomplished by selecting and moving groups of keys in the track view and then making a preview to check your changes.  
AI types (actions)
There are a number of animations that the AI can use:  


	ACT_IDLE = 1,
	ACT_GUARD,
	ACT_WALK,
	ACT_RUN,
	ACT_FLY,				// Fly (and flap if appropriate)
	ACT_SWIM,
	ACT_HOP,				// vertical jump
	ACT_LEAP,				// long forward jump
	ACT_FALL,
	ACT_LAND,
	ACT_STRAFE_LEFT,
	ACT_STRAFE_RIGHT,
	ACT_ROLL_LEFT,			// tuck and roll, left
	ACT_ROLL_RIGHT,			// tuck and roll, right
	ACT_TURN_LEFT,			// turn quickly left (stationary)
	ACT_TURN_RIGHT,			// turn quickly right (stationary)
	ACT_CROUCH,				// the act of crouching down from a standing position
	ACT_CROUCHIDLE,			// holding body in crouched position (loops)
	ACT_STAND,				// the act of standing from a crouched position
	ACT_USE,
	ACT_SIGNAL1,
	ACT_SIGNAL2,
	ACT_SIGNAL3,
	ACT_TWITCH,
	ACT_COWER,
	ACT_SMALL_FLINCH,
	ACT_BIG_FLINCH,
	ACT_RANGE_ATTACK1,
	ACT_RANGE_ATTACK2,
	ACT_MELEE_ATTACK1,
	ACT_MELEE_ATTACK2,
	ACT_RELOAD,
	ACT_ARM,				// pull out gun, for instance
	ACT_DISARM,				// reholster gun
	ACT_EAT,				// monster chowing on a large food item (loop)
	ACT_DIESIMPLE,
	ACT_DIEBACKWARD,
	ACT_DIEFORWARD,
	ACT_DIEVIOLENT,
	ACT_BARNACLE_HIT,		// barnacle tongue hits a monster
	ACT_BARNACLE_PULL,		// barnacle is lifting the monster ( loop )
	ACT_BARNACLE_CHOMP,		// barnacle latches on to the monster
	ACT_BARNACLE_CHEW,		// barnacle is holding the monster in its mouth ( loop )
	ACT_SLEEP,
	ACT_INSPECT_FLOOR,		// for active idles, look at something on or near the floor
	ACT_INSPECT_WALL,		// for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall )
	ACT_IDLE_ANGRY,			// alternate idle animation in which the monster is clearly agitated. (loop)
	ACT_WALK_HURT,			// limp  (loop)
	ACT_RUN_HURT,			// limp  (loop)
	ACT_HOVER,				// Idle while in flight
	ACT_GLIDE,				// Fly (don't flap)
	ACT_FLY_LEFT,			// Turn left in flight
	ACT_FLY_RIGHT,			// Turn right in flight
	ACT_DETECT_SCENT,		// this means the monster smells a scent carried by the air
	ACT_SNIFF,				// this is the act of actually sniffing an item in front of the monster
	ACT_BITE,				// some large monsters can eat small things in one bite. This plays one time, EAT loops.
	ACT_THREAT_DISPLAY,		// without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc )
	ACT_FEAR_DISPLAY,		// monster just saw something that it is afraid of
	ACT_EXCITED,			// for some reason, monster is excited. Sees something he really likes to eat, or whatever.
	ACT_SPECIAL_ATTACK1,	// very monster specific special attacks.
	ACT_SPECIAL_ATTACK2,	
	ACT_COMBAT_IDLE,		// agitated idle.
	ACT_WALK_SCARED,
	ACT_RUN_SCARED,
	ACT_VICTORY_DANCE,		// killed a player, do a victory dance.
	ACT_DIE_HEADSHOT,		// die, hit in head. 
	ACT_DIE_CHESTSHOT,		// die, hit in chest
	ACT_DIE_GUTSHOT,		// die, hit in gut
	ACT_DIE_BACKSHOT,		// die, hit in back
	ACT_FLINCH_HEAD,
	ACT_FLINCH_CHEST,
	ACT_FLINCH_STOMACH,
	ACT_FLINCH_LEFTARM,
	ACT_FLINCH_RIGHTARM,
	ACT_FLINCH_LEFTLEG,
	ACT_FLINCH_RIGHTLEG,

Scripted sequences
These are sequences that are designed for a specific place.  You can use the .dxf exporter in WorldCraft to bring part of a Half-Life level into Max, and then tailor your animation to fit precisely into it.  
Programmatic (bone controllers)
As mentioned earlier, you can designate portions of the model to be oriented by the AI.  The game uses this to control the turrets, creature heads, helicopter guns, etc.  You can pass off control of any bone to the AI. The section below describes this in detail.
Creating good loops
Most of the time when animating, you are making a small section that is designed to loop.  You may think that if you make the first and last frame identical, that your job is done, but there are some tricks you can use to make the loop even smoother.
Track View
If you are using standard bones (not biped parts) you can use the track view to create loops for you.  This involves editing ranges and using the parameter curve out types interface.
Parameter curve out types
Use the loop option, and define the length of your loop with the edit ranges button, this uses the exiting key frames and adjusts the curves to smooth out interpolation.  Instead of having identical keyframes on the first and last frame, the last frame smoothly interpolates into the first.  It is not necessary to have any keys on the last frame, Max will generate the motion for you.
Motion extraction/constant root movement
One easy thing to miss is inconstant root movement: that is, if you have a character moving in your animation, the motion of the root bone must be constant.  Use the edit curves button in the track view to see what is really going on with your root movement.  If the curve is not straight in the active time segment, the motion extraction in the .qc file will not be able to remove the motion accurately and you will have some degree of sliding.  If you are using a biped, you won't have this problem if you are using footsteps, but if you are dong a free-form walk or run, put an extra key one frame before and after your active time segment to make the active portion linear. If you have a thirty frame loop, make a keyframe at frame one and thirty one: this will be your active time segment.  To get your forward curve to be straight, make an extra forward motion keyframe at frame 0 and 32: if you look at the function curve, it will now be straight, indicating constant motion. 
Export Process
The exporter lives in the export window of Max.  The only thing you have to do for each animation is export it with the "skeletal animation" button checked.  The option for vertex deformation is turned off (this feature is not supported by the engine).  You'll need to export your character as a reference frame once as well.  
Max exporter
To get this to work, all you need to do is drop two files into your stdplugs directory.  The two file are: smdlexp.dle and smdlexp.ilk.
QC files
The .qc file is the link between the AI code and the art (models, animations).  Studiomdl.exe uses the .qc file to assemble all the component files into one .mdl file for each character.  Below is a sample .qc file (Gargantua).
/*

garg.qc 

*/

$scale 1.0

// garg.smd
$modelname valve/models/garg.mdl
$cd valve/models/garg
$cdtexture valve/models/garg/maps_8bit

$body studio "garg_template_biped1"

$attachment 0 "Bip01 Head" 10 17 0 X 1
$attachment 1 "Bip01 R Arm2" 53 5 0 X 1
$attachment 2 "Bip01 L Arm2" 53 5 0 X 1

$controller 0 "Bip01 Spine" XR -45 45
$controller 1 "Bip01 Spine" ZR -35 35

$eyeposition 0 0 139
//$eyeposition 0 67 139

$hbox 0 "Bip01 Pelvis" -32.14 -41.99 -33.62  102.14 43.81 36.09
$hbox 0 "Bip01 L Leg" -15.19 -22.76 -9.05  50.06 16.42 15.99
$hbox 0 "Bip01 L Leg1" 0.00 -23.19 -9.21  37.02 16.80 12.41
$hbox 0 "Bip01 L Foot" -5.78 -28.02 -21.43  25.57 49.80 17.84
$hbox 0 "Bip01 L Toe0" -1.64 0.00 -12.73  10.48 7.43 13.37
$hbox 0 "Bip01 L Toe1" 0.00 -0.73 -11.49  21.22 10.27 8.01
$hbox 0 "Bip01 L Toe2" -3.30 -0.08 -13.69  8.83 7.15 12.41
$hbox 0 "Bip01 R Leg" -15.14 -22.75 -13.17  49.78 16.37 8.73
$hbox 0 "Bip01 R Leg1" 0.00 -23.14 -11.52  37.02 16.91 10.28
$hbox 0 "Bip01 R Foot" -5.78 -28.05 -18.75  25.57 45.62 20.98
$hbox 0 "Bip01 R Toe0" -4.19 0.00 -13.38  10.04 7.60 12.72
$hbox 0 "Bip01 R Toe1" 0.00 -0.73 -8.92  21.19 10.27 10.78
$hbox 0 "Bip01 R Toe2" -2.39 -0.08 -12.43  9.73 7.16 13.66
$hbox 0 "Bip01 Spine" -2.88 -59.95 -34.81  35.32 31.89 36.71
$hbox 0 "Bip01 Spine1" -4.05 -71.68 -33.43  43.22 54.10 35.89
$hbox 0 "Bip01 Spine2" 0.00 -76.40 -38.53  37.29 16.82 41.00
$hbox 0 "Bip01 Spine3" -12.17 -62.48 -43.39  26.09 36.90 45.00
$hbox 0 "Bip01 Spine4" -14.53 -46.62 -34.95  19.41 33.41 37.42

// edited to stop eye from being occluded
$hbox 1 "Bip01 Head" -1.52 -24.04 -10.17  16.00 15.00 13.05
$hbox 3 "Bone07" -12.49 -16.00 -8.82  0.00 4.00 8.54
//

$hbox 0 "Bip01 L Arm" -4.56 -26.70 -34.31  12.61 25.90 16.29
$hbox 0 "Bip01 L Arm1" -7.24 -18.86 -18.46  57.55 16.32 21.88
$hbox 0 "Bip01 L Arm2" -0.83 -15.96 -19.03  73.73 20.16 19.46
$hbox 0 "Bone36" -16.97 -27.86 -0.09  0.00 0.00 5.61
$hbox 0 "Bone26" -36.10 -26.51 -5.84  0.00 0.00 10.03
$hbox 0 "Bone23" -17.38 -45.29 0.00  0.00 0.00 14.03
$hbox 0 "Bip01 R Arm" -3.83 -21.85 -16.58  11.71 26.16 33.92
$hbox 0 "Bip01 R Arm1" -7.11 -19.39 -21.44  57.12 17.06 16.47
$hbox 0 "Bip01 R Arm2" -0.80 -14.97 -20.24  73.73 19.31 18.15
$hbox 0 "Bone33" -17.56 -27.43 -5.24  0.00 0.00 0.46
$hbox 0 "Bone20" -18.17 -44.95 -13.92  0.00 2.87 1.18
$hbox 0 "Bone29" -36.89 -25.39 -8.11  0.00 0.00 7.62
$hbox 0 "Bone39" -3.75 0.00 -9.53  6.96 12.26 9.76
$hbox 0 "Bone15" -9.96 -15.40 -3.21  7.03 9.05 5.86
$hbox 0 "Bone16" -17.30 -9.50 -3.63  0.00 0.00 2.97
$hbox 0 "Bone17" -13.43 -22.43 -2.96  4.60 5.07 4.48
$hbox 0 "Bone10" -9.74 -15.22 -5.85  2.14 9.23 3.22
$hbox 0 "Bone11" -20.62 -9.32 -2.96  1.89 0.00 3.64
$hbox 0 "Bone12" -13.59 -22.53 -2.50  4.44 0.89 3.09
$hbox 0 "Bone01" -6.59 -4.93 -4.24  0.00 0.20 2.34
$hbox 0 "Bone02" -12.04 -8.52 -3.25  0.00 0.00 1.47
$hbox 0 "Bone03" -11.66 -8.41 -2.72  0.00 0.00 0.03
$hbox 0 "Bone04" -10.59 -7.48 -1.60  0.00 0.00 0.00

$sequence idle3 "garg_idle1(subtle)" LOOP fps 10 ACT_IDLE 3 { event 6 8 }
$sequence idle2 "garg_fidget1(roar)" fps 10 ACT_IDLE 1 { event 1008 7 "garg/gar_attack1.wav" }
$sequence idle1 "GARG_Fidget1(Shake)" fps 15 ACT_IDLE 1
$sequence idle4 "GARG_Fidget1(seek)" fps 10 ACT_IDLE 1
$sequence walk "garg_walk1" LX loop fps 14 ACT_WALK 5 { event 3 1 } { event 6 7 } { event 4 18 }
//$sequence WalkRoar "garg_Walk_Roar1" LX loop fps 14 ACT_IDLE 1 { event 1008 12 "garg/gar_attack3.wav" }
//$sequence walk2 "garg_walk2(tounge)" LX loop fps 14 ACT_WALK 1 { event 3 1 } { event 6 12 } { event 4 18 }
//$sequence walktostandr "GARG_Walk_to_Stand(Rght-foot)" fps 14
//$sequence walktostandl "garg_walk_to_stand(lft-foot)" fps 14
//$sequence stomp "garg_stomp1" fps 14 ACT_RANGE_ATTACK1 1 { event 5 15 }
$sequence stomp "garg_stomp2(Short)" fps 14 ACT_RANGE_ATTACK1 1 { event 5 19 }
$sequence shootflames1 "GARG_FlameShoot1" fps 15 ACT_SIGNAL1 1
$sequence shootflames2 "GARG_FlameShoot(Cycler)1" loop fps 8 ACT_MELEE_ATTACK2 1
$sequence 180left "garg_turn_left1" fps 7 ACT_TURN_LEFT 1
$sequence 180right "garg_turn_right1" fps 7 ACT_TURN_RIGHT 1
$sequence Flinchlight "garg_Flinch(light)1" fps 14 ACT_SMALL_FLINCH 1
$sequence Flinchheavy "garg_Flinch(Heavy)1" fps 14 ACT_BIG_FLINCH 1
$sequence Attack "GARG_Attack(Swing)1" fps 18 ACT_MELEE_ATTACK1 1 { event 1 28 }

$sequence die "GARG_die1" fps 15 ACT_DIESIMPLE 1

//Gargantuan fighting human grunt animations

$sequence bitehead "..\cinematics\gargantuan_tunnel\garg_bitehead_garg" {
	origin -6 -251 0
	AX AY AZR
	scale 1.0
	fps 16
} 
$sequence throwbody "..\cinematics\gargantuan_tunnel\garg_throw_garg" {
	AX AY AZR
	scale 1.0
	fps 16
}
$sequence smash "..\cinematics\gargantuan_tunnel\garg_smash_garg" {
	AX AY AZR
	scale 1.0
	fps 16
}


Directory structure
The first part of the .qc file tells studiomdl where to look for the .smd files and the .bmp files (in dark blue).  This also tells studiomdl.exe where to place the final .mdl file
Body groups
The next section, in red, tells studiomdl what the reference file is, this is where all texture, geometry and smoothing group info is stored.
Activities
In each of the blue animation lines there is an entry that starts with "ACT_", these are activities that the ai can use.  
Fps
In each of the blue animation lines there may be a notation of fps followed by a number: if this isn't present the animation will play at whatever speed it was animated at.  To change the speed of an animation, simply supply a new value.
Weights
Following the activity, there is a number: this is the weight, and is used to allow the engine to randomly play different animation sequences for a given activity and tells it how often to play which animation.  You can supply any number of animations for an activity and then change the value at which instance is played.  For example, you could give a character 3 walk animations, label them all ACT_WALK and then give them a weight to affect how likely each one will play.  The number you supply is a multiplier, a 5 is five times more likely to play than a weight of 1.
Names vs. Filenames
In blue animation line you have a name followed by a filename in quotes:

$sequence stomp "garg_stomp2(Short)" fps 14 ACT_RANGE_ATTACK1 1 { event 5 19 }

The name here is "stomp", the .smd filename is "garg_stomp2(Short)". When calling a specific animation to be used in a scripted_sequence in WorldCraft, refer to it by the name "stomp", not the filename "garg_stomp2(Short)".
Animation events
In the example above, the last part is an animation event.  These are used in the AI code to link effects (sound, sprites, etc.) to a particular frame of the animation
Root Movement extraction
When you animate a movement animation, you leave the forward motion in the file.  The motion is extracted in the .qc file by including an LX, LY, or LZ in the animation line, you can use any combination of these.
Blending
Attachment Points
The attachment points for the gargantua are listed in olive near the begenning.  These are points on the mesh from which you can spawn f/x.
Bone controllers
You can assign any bone of the body to be controlled by the AI.  The bone controllers for the Gargantua are listed near the beginning in green.  The two listed give control of the base of the spine to the ai, each axis of rotation needs it's own controller, the first one here controls the limits of the X ( up and down) rotation the numbers at the end of the line define the range of motion for that axis.  The second line controlls the z rotation.

$controller 0 "Bip01 Spine" XR -45 45
$controller 1 "Bip01 Spine" ZR -35 35
Scaling

You may scale the model as a whole and on a per animation basis by adding the "scale x" where x is the desired value.
Studio Model (Studiomdl.exe)
There are a few options on running studiomdl, but for your final model compile, all you should need to run is "studiomdl <filename>".  Some options are turned off in the code, but can be turned back on if you wish (we have released the source code to studiomdl, so folks can recompile it with new options if they want, or use it to create, for example, a Lightwave exporter.)

The command line options of interest are:

-a <value>
This blends surface normals together into single surfaces, optimizing the model in memory.  The default value is 2, which should suffice for everything you do.  It can be played with at your discretion, however.

-h
Output hitbox info.  If you run with this option and redirect your screen output into a text file, studiomdl will generate a list of the hitbox sizes for each bone of your creature.  It generates these hitboxes automatically, but sometimes doesa less than optimal job.  If you redirect this information into a text file, then you can cut and paste that information back into the .qc file and edit the information, basically adjusting certain bone hit boxes by hand.  Doing this will allow for a more accurate representation of the model for determining whether or not shots hit the creature.

-i
Ignore warnings.  Useful if there are undone aspects to the model, yet you wish to test it out anyway.

-t <bmpname>
Replace all textures on the model with a single texture.  Useful for testing smoothing groups, but can also be mimicked with the "r_drawentities" console variable.

-t <sourcetexturename> <replacementtexturename>
This allows you to replace one texture within a model with another texture.  We used this most often in testing out different chrome maps on models, to see which one we liked best, because with chrome maps you need not worry about texture alignment, so this sort of post-process texture substitution worked out well.  It can be done with any texture, however, although for final model compiles, it's best to define exactly which texture you want in the actual .max file.

Below is the list of all the internal studiomdl commands:

$modelname <path>
$cd <path>
$cdtexture <path> [<path> ...]
$scale #
$controller # <bone>
$body <name> <path> [reverse] [scale]
$bodygroup <name>
$sequence <name> <smd path> [<smd path> ... ]  [event <#> <frame> [options]]  [fps <#>] [origin <X> <Y> <Z>] [rotate <angle>] [scale <#>] [loop] [frame <start> <end>] [blend <axis> <start> <end>] [node <#>] [transition <start> <end>] [rtransition <start> <end>]
$sequencegroup <name>
$sequencegroupsize <# in KB>
$eyeposition <X> <Y> <Z>
$origin <X> <Y> <Z>
$bbox <X> <Y> <Z> <X> <Y> <Z>
$cbox <X> <Y> <Z> <X> <Y> <Z>
$mirrorbone <bone>
$gamma <src value>
$flags <#>
$texturegroup <name> { }
$hgroup <group #> <bone> 
$hbox <group #> <bone> <X> <Y> <Z> <X> <Y> <Z>
$attachment <#> <bone> <X> <Y> <Z>
$externaltextures
$cliptotextures



